import axios from 'axios'

export default {
  namespaced: true,
  state: {
    categtory: [],
    currentCategtory: ''
  },
  mutations: {
    updateCategtory (state, payload) {
      state.categtory = payload
    },
    updataCurrentCategtory (state, payload) {
      state.currentCategtory = payload
    }
  },
  actions: {
    async getCategtory (context) {
      const { data: { data: { channels } } } = await axios.get('http://ttapi.research.itcast.cn/app/v1_0/channels')
      context.commit('updateCategtory', channels)
      context.commit('updataCurrentCategtory', channels[0].id)
    }
  }
}
